﻿using MyUAMS.BLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class MyInformation_MyAllinformation : System.Web.UI.Page
{
    WorkServer workSrc = new WorkServer();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Bind();
        }
    }
    public void Bind()
    {
        if (Session["CustomerId"] != null)
        {
            int uid = int.Parse(Session["CustomerId"].ToString());
            var Information = workSrc.GetMyBR(uid);
            if(Information.Count() != 0)
            {
                dgvInformation.DataSource = Information;
                dgvInformation.DataBind();
            }
            else
            {
                lblProErr.Text = "没有消息";
            }
            
        }
        else
        {
            lblProErr.Text = "未登录";
        }
        
    }

    protected void return_Click(object sender, ImageClickEventArgs e)
    {
        // 获取触发事件的 ImageButton
        ImageButton returnButton = sender as ImageButton;

        // 确保返回按钮不为 null
        if (returnButton != null)
        {
            // 获取包含 ImageButton 的 GridViewRow
            GridViewRow row = returnButton.NamingContainer as GridViewRow;

            // 确保行不为 null
            if (row != null)
            {
                // 从 DataKeys 集合中获取 APid
                int apid = Convert.ToInt32(dgvInformation.DataKeys[row.RowIndex].Value);
                lblProErr.Text = apid.ToString();
                // 构建跳转 URL 并传递参数 APid
                string redirectUrl = "../UserWork/UpdataAmount.aspx?APid=" + apid;

                // 重定向到目标页面
                Response.Redirect(redirectUrl);
            }
        }
    }
}